using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using SystemX.WebControls.XPaging;

public partial class UrlRewriting_Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //cache the number of total records to improve performance
            object obj = Cache[GetType()+"totalOrders"];
            if (obj == null)
            {
                int totalOrders = (int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "P_GetOrderNumber");
                Cache[GetType()+"totalOrders"] = totalOrders;
                XPager1.RecordCount = totalOrders;
				yPager1.TotalItems = totalOrders;
            }
            else
            {
                XPager1.RecordCount = (int)obj;
				yPager1.TotalItems = (int)obj;
            }
        }
    }
    
    protected void XPager1_PageChanged(object src, EventArgs e)
    {
        DataList1.DataSource = SqlHelper.ExecuteReader(CommandType.StoredProcedure, ConfigurationManager.AppSettings["pagedSPName"],
            new SqlParameter("@startIndex", XPager1.StartRecordIndex),
            new SqlParameter("@endIndex", XPager1.EndRecordIndex));
        DataList1.DataBind();
    }
	protected void yPager1_PageChanging(object src, PageChangingEventArgs e)
	{
	}

	protected void yPager1_PageChanged(object src, EventArgs e)
	{
		DataList1.DataSource = SqlHelper.ExecuteReader(CommandType.StoredProcedure, ConfigurationManager.AppSettings["pagedSPName"],
	new SqlParameter("@startIndex", yPager1.StartIndex),
	new SqlParameter("@endIndex", yPager1.EndIndex));
		DataList1.DataBind();
	}
}
